package com.ibangnuo.manage.controller.commercial;

import com.ibangnuo.api.commercial.CommercialMigrationControllerApi;
import com.ibangnuo.framework.domain.CommercialMigration;
import com.ibangnuo.framework.domain.request.commercial.CommercialMigrationRequest;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.manage.service.commercial.CommercialMigrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: wwy
 * @Date: 2020-03-11 9:36
 * 商户迁移
 */
@RestController
@RequestMapping("/commercialMigration")
public class CommercialMigrationController implements CommercialMigrationControllerApi {
    @Autowired
    private CommercialMigrationService commercialMigrationService;
    /**
     * 新增商户迁移记录
     * @param commercialMigration
     * @return
     */
    @PostMapping("/migrate")
    @Override
    public ObjectResult migrate(@RequestBody CommercialMigration commercialMigration) {
        return commercialMigrationService.migrate(commercialMigration);
    }

    /**
     * 分页条件查询
     * @param page
     * @param size
     * @param commercialMigrationRequest
     * @return
     */
    @PostMapping("/findList/{page}/{size}")
    @Override
    public QueryResponseResult findList(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody CommercialMigrationRequest commercialMigrationRequest) {
        return commercialMigrationService.findList(page,size,commercialMigrationRequest);
    }

    /**
     * 新增批量商户迁移记录
     * @param commercialMigrationList
     * @return
     */
    @PostMapping("/migrateList")
    @Override
    public ObjectResult migrateList(@RequestBody List<CommercialMigration> commercialMigrationList) {
        return commercialMigrationService.migrateList(commercialMigrationList);
    }
}
